const changeCompanyArr = (data) => { // 修改后台传送过来的数据结构
  let nData = []
  for (let i = 0; i < data.length; i++) { // 1
    let obj1 = {}
    let city = data[i].city
    let company = data[i].company
    obj1.label = city
    obj1.value = city
    obj1.children = []

    for (let j = 0; j < company.length; j++) { // 2
      let obj2 = {}
      let id = company[j].id
      let name = company[j].name
      let localCompanyNameVOList = company[j].localCompanyNameVOList
      obj2.label = name
      obj2.value = id
      obj2.children = []
      obj1.children.push(obj2)

      for (let z = 0; z < localCompanyNameVOList.length; z++) { // 3
        let obj3 = {}
        let localDepartmentNameVOList = localCompanyNameVOList[z].localDepartmentNameVOList
        let name = localCompanyNameVOList[z].name
        obj3.label = name
        obj3.value = name
        obj3.children = []
        obj2.children.push(obj3)

        for (let x = 0; x < localDepartmentNameVOList.length; x++) { // 4
          let obj4 = {}
          let name = localDepartmentNameVOList[x].name
          let listLineShort = localDepartmentNameVOList[x].listLineShort
          obj4.label = name
          obj4.value = name
          obj4.children = []
          obj3.children.push(obj4)

          for (let y = 0; y < listLineShort.length; y++) { // 5
            let obj5 = {}
            let name = listLineShort[y].name
            obj5.label = name
            obj5.value = name
            obj4.children.push(obj5)
          }
        }
      }
    }
    nData.push(obj1)
  }
  return nData
}

export default changeCompanyArr
